#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    // 初始化下拉框的内容
    ui->comboBox->addItem("巨无霸");
    ui->comboBox->addItem("鸡腿堡");
    ui->comboBox->addItem("牛肉堡");

    ui->comboBox_2->addItem("麦辣鸡翅");
    ui->comboBox_2->addItem("中薯条");
    ui->comboBox_2->addItem("麦乐鸡块");

    ui->comboBox_3->addItem("可乐");
    ui->comboBox_3->addItem("雪碧");
    // 设置 微调框 的范围
    ui->spinBox->setRange(1,5);
    ui->spinBox_2->setRange(1,5);
    ui->spinBox_3->setRange(1,5);
    // 设置微调框的 输入有误时的修正模式
    ui->spinBox->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
    ui->spinBox_2->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
    ui->spinBox_3->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
    // 设置微调框的每次调整的步长
    ui->spinBox->setSingleStep(1);
    ui->spinBox_2->setSingleStep(1);
    ui->spinBox_3->setSingleStep(1);
    // 设置微调框的数字的进制
    ui->spinBox->setDisplayIntegerBase(10);
    ui->spinBox_2->setDisplayIntegerBase(10);
    ui->spinBox_3->setDisplayIntegerBase(10);
    // 设置微调框的后缀
    ui->spinBox->setSuffix("份");
    ui->spinBox_2->setSuffix("份");
    ui->spinBox_3->setSuffix("份");
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    // 点击提交后，打印所选的套餐
    qDebug() << ui->comboBox->currentText() << ":" << ui->spinBox->value();
    qDebug() << ui->comboBox_2->currentText() << ":" << ui->spinBox_2->value();
    qDebug() << ui->comboBox_3->currentText() << ":" << ui->spinBox_3->value();
}
